import 'package:flutter/material.dart';

class HomeWdiget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    List<Widget> list = new List<Widget>();
    List<String> msg = <String>[
      "这周的周报发我一下",
      "过来看个报错",
      "[微信红包]",
      "这个你一看就会了",
      "周末出来打球",
      "程序又报错了",
      "在吗？",
      "收到",
      "这个需求你们做没",
      "周六回家吗?"
    ];
    List<String> dates = <String>[
      "昨天",
      "12:11",
      "一周前"
    ];

    List<String> contact_name = <String>[
      "代权",
      "王辉",
      "李俊魁",
      "吕光辉",
      "戴鹏达",
      "陈耀栋",
      "Christ",
      "陈建",
      "陈道金",
      "程简"
    ];

    List<String> contact_icon = <String>[
      'assets/images/head_daiquan.jpg',
      'assets/images/head_wanghui.jpg',
      'assets/images/head_lijunkui.jpg',
      'assets/images/head_lvgh.jpg',
      'assets/images/head_daipengda.jpg',
      'assets/images/head_chenyaodong.jpg',
      'assets/images/head_who.jpg',
      'assets/images/head_chenjian.jpg',
      'assets/images/head_chendj.jpg',
      'assets/images/head_chengjian.jpg',
    ];

    for (int i=0; i<contact_icon.length; i++) {
      list.add(
        SizedBox(
          width: double.infinity,
          height: 64,
          child: Container(
              color: Color(0xFEFEFE),
              child: Container(
                child: ConstrainedBox(
                  constraints: BoxConstraints.expand(),
                  child: Stack(
                    alignment: Alignment.centerLeft,
                    children: <Widget>[
                      // 头像
                      Positioned(
                        top:6,
                        left: 6,
                        width: 46,
                        height: 46,
                        child: Container(
                        decoration: BoxDecoration(
                          borderRadius: BorderRadius.circular(3),
                            image: DecorationImage(
                              image: AssetImage(contact_icon[i%contact_icon.length]),
                              fit: BoxFit.cover
                            )
                          ),
                        ),
                      ),
                      // 昵称
                      Positioned(
                        top:10,
                        left: 61,
                        child: Text(contact_name[i%contact_name.length], style: TextStyle(fontSize: 16, color: Color(0xFF060606)),),
                      ),
                      // 最近一次聊天内容
                      Positioned(
                        top:32,
                        left: 61,
                        child: Text(msg[i%msg.length], style: TextStyle(fontSize: 12, color: Color(0xFF909090)),),
                      ),
                      //分割线
                      Positioned(
                        top:31,
                        left: 61,
                        width: 300,
                        height: 63,
                        child: Divider(
                            color: Colors.grey[350],
                          )
                      ),
                      // 日期
                      Positioned(
                        top:10,
                        right: 18,
                        child: Text("9月12日", style: TextStyle(color: Color(0xFFA1A1A1), fontSize: 12),),
                      )
                    ],
                  ),
                ),
              ),
            ),
        )
      );
    }

    return ListView(
      //padding: EdgeInsets.only(top: 10),
      children: list
    );
  }
  
}